define("p_more", ["m_basepage", 'text!T_UIMoreView', "m_tpl", "m_zepto"], function(Basepage, T_UIMoreView) {

	var h = Basepage.extend({
		initialize: function() {
			this.page.viewId = '#p-view-more', this.page.name = "p_view_more", this.page.html = '';
			this._renderHTML();
		},
		enter: function() {},
		back: function() {},
		leave: function() {},
		_renderHTML: function() {
			var self = this;
			self.page.html = (_.template(T_UIMoreView))({
				sessionkey: localStorage.getItem('sessionkey'),
				pageName: self.page.name
			});
			self.pageAdd();
			self.init();
		},
		bindMethod: function() {
			var e = this,
				a = this.jdom;
			a.delegate('#customerappellation', 'click', function(_this) {
				if(islogin()) {
					window.location.href = 'account.html';
				} else {
					judgeJumpReloginUrl('login.html?autoHref=account.html')
				}
			});
			a.delegate('.btn-exit', 'click', function() {
				clearLocVal("sessionkey,idtype");
				judgeJumpReloginUrl('login.html?autoHref=account.html')
			});
			a.delegate('.js-signin', 'click', function() {
				window.location.href = 'signin.html';
			});
			a.delegate('.js-customer+div', 'click', function() {
				window.location.href = 'accountRank.html';
			});
			a.delegate('.js-customer+div+div', 'click', function() {
				if(!islogin()) {
					judgeJumpReloginUrl('login.html?autoHref=index.html');
					return;
				}
				window.location.href = 'personalProfile.html';
			});
			a.delegate('li', 'click', function() {
				var index = $(this).data('index');
				switch(index) {
					case 1: //定投:验证登录
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							//  judgeJumpReloginUrl('login.html?autoHref=cleverInvest/eFixed_manage.html');
							return;
						}
						if(getLocVal('originalString') === 'DCVALID' || getLocVal('custType') === 'W') {
							dialogConfirm('您尚未实名认证，不能进行此操作，是否立即实名认证？', '实名认证', 'authenImme.html');
							return;
						}
						window.location.href = 'cleverInvest/eFixed_manage.html';
						//  window.location.href = 'investMgr.html';
						break;
					case 2: //银行卡:验证登录——>验证是否代销客户
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							//judgeJumpReloginUrl('login.html?autoHref=bankcardMgr.html');                       
							return;
						}
						if(getLocVal('originalString') == 'DCVALID' || getLocVal('custType') == 'W') { //弱认证用户/代销客户
							dialogConfirm('您尚未实名认证，不能进行此操作，是否立即实名认证？', '实名认证', 'authenImme.html');
							return;
						} else {
							window.location.href = 'bankcardMgr.html';
						}
						break;
					case 3: //实名认证
						window.location.href = "authenImme.html";
						break;
					case 4: //个人信息
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							//  judgeJumpReloginUrl('login.html?autoHref=personalProfile.html');
							return;
						}
						window.location.href = 'personalProfile.html';
						break;

					case 5: //我的积分
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							// judgeJumpReloginUrl('login.html?autoHref=jfRecord.html');
							return;
						}
						window.location.href = 'jfRecord.html';
						break;
					case 6: //邀请有礼
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							// judgeJumpReloginUrl('login.html?autoHref=shareToFriend.html');
							return;
						}
						window.location.href = 'shareToFriend.html';
						break;
					case 8: //关于南方
						window.location.href = "about.html";
						break;
					case 9: //设置
						window.location.href = 'accountSetting.html';
						break;
					case 10:
						window.location.href = 'vip.html';
						break;

					case 13:
						$('.mes-count').addClass('uhide');
						window.location.href = 'publishMsgCenter.html';
						break;
					case 99:
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							return;
						}
						window.location.href = 'guessupdown/nfjj_index.html';
						break;
					case 999:
						window.location.href = 'account/fillMes.html';
						break;
					case 88:
						window.location.href = 'fixincome/fixCal.html';
						break;
					case 16: //优惠券
						if(!islogin()) {
							judgeJumpReloginUrl('login.html?autoHref=index.html');
							return;
						}
						window.location.href = "coupon/couponOfMine.html";
						break;
						// case 3://关注
						// window.location.href = "interested.html";
						// break;
						// case 4://消息
						// window.location.href = "publishMsgCenter.html";
						// break; 
						// case 5://实名认证
						// window.location.href = 'authenImme.html';
						// break;
						// case 6://余额理财;
						// if(!islogin()) {
						// judgeJumpReloginUrl('login.html?autoHref=balanceMgr.html');
						// return;
						// }
						// if(getLocVal('originalString')=== 'DCVALID'||getLocVal('custType') === 'W') {
						// dialogConfirm('您尚未实名认证，不能进行此操作，是否立即实名认证？','实名认证','authenImme.html');
						// return;
						// }
						// window.location.href = 'balanceMgr.html';
						// break;
						// case 7:
						// window.location.href = 'authentication.html';
						// break;
						// case 9://手机快捷登录
						// if(!islogin()) {
						// judgeJumpReloginUrl('login.html?autoHref=accountBind.html');
						// return;
						// }
						// window.location.href = 'accountBind.html';
						// break;
						// case 10://设置
						// window.location.href = 'accountSetting.html';
						// break;
						// case 11://资讯中心
						// window.location.href = 'zixun.html';
						// break;
				}
			});
		}
	});
	new h

	$(function() {

		if(islogin()) {
			if(!iswechat() || getLocVal('originalString') != 'DCVALID') {
				$('.js-exit').removeClass('uhide');
			}
			$('.js-exit').on('click', function() {
				//dialogConfirm('是否确认退出本次登录','确定','index.html#p_view_more');
				dialog({
					type: 'confirm',
					hasTitle: false,
					content: '安全退出后下次进入需要验证密码，您也可直接点击左上方按钮退出本页面',
					button: {
						cancel: '取消',
						confirm: '继续安全退出'
					},
					cancelCallback: null,
					confirmCallback: function() {
						clearLocVal("sessionkey,idtype");
						localStorage.setItem("safeExit", "1");
						sessionStorage.removeItem("loginflag")
						sessionStorage.removeItem("debLock")
						location.href = 'index.html';
					}
				});
				return;
			});
		}

		if(islogin()) {
			if(localStorage.getItem("isFirstLogin") == '1' && localStorage.getItem("openMobileLogin") == '0') {
				dialogConfirm('您尚未开通手机号快捷登陆功能，是否立即开通？', '确定', 'accountBind.html');
				return;
			}
			showUserinfo(true);
		} else {
			$('.js-customer+div').addClass('uhide');
			$('.js-customer+div+div').removeClass('uhide');
		}
		// 签到
		$('.js-signin').on('click', function() {
			window.location.href = 'signin.html';
		});
		// 积分等级说明
		$('#scoreIntro').on('click', function() {
			window.location.href = 'jfRecord.html';
		});
		//客户登记说明
		$('.js-userRank').on('click', function() {
			window.location.href = 'accountRank.html';
		});
		$('.js-customer').on('click', function() {
			if(!islogin()) {
				judgeJumpReloginUrl('login.html?autoHref=personalProfile.html');
				return;
			}
			window.location.href = 'personalProfile.html'; //个人资料
		});

	});

	function showMesCount(msgcnt) {
		if(msgcnt && msgcnt != 0) {
			// var str = ' <div class="mes-count" >'
			// +(msgcnt>99?'<span class=" ub ub-ac ub-pc" style="padding:0 .3em;font-size:.74em;">99+</span>':(msgcnt>9?'<span class=" ub ub-ac ub-pc" style="font-size:.8em;">'+msgcnt+'</span>':msgcnt))
			// +'</div>';
			var str = (msgcnt > 99 ? '<span class=" ub ub-ac ub-pc" style="padding:0 .3em;font-size:.74em;">99+</span>' : (msgcnt > 9 ? '<span class=" ub ub-ac ub-pc" style="font-size:.8em;">' + msgcnt + '</span>' : msgcnt));
			$('.mes-count').html(str);
			$('.mes-count').removeClass('uhide');
		}
		// msgcnt>99?$('.mes_icon ').html('99+'):$('.mes_icon ').html(msgcnt);
		// $('.mes_icon ').removeClass('uhide');

	}

	function showUserinfo(initflag) {
		$('.js-customer+div').removeClass('uhide');
		$('.js-customer+div+div').addClass('uhide');
		$('.js-userRank').removeClass('uhide'); //客户是普通还是白金显示出来

		$('.js-signin').removeClass('uhide');
		$('.js-login').addClass('uhide').next().removeClass('uhide');
		if(localStorage.getItem("custType") == 'S') { //弱认证客户W，强认证客户S
			$('.js-username').text(Decrypt(sessionStorage.getItem("customerappellation"))); //客户姓名
		} else {
			$('.js-username').text(replaceByStar(sessionStorage.getItem('handset'), 3, 4)); //手机号注册
		}
		if(localStorage.getItem("custType") == 'W' || localStorage.getItem("originalString") == 'DCVALID') { //弱认证用户/纯代销客户
			$('.js-list-authen').removeClass('uhide'); //实名认证
			//$('.js-authen').css('background-color','#ed4300').text('未认证');
			$('.blueDot').addClass('uhide');
			$('.js-authen').html('未实名');
		} else {
			$('.js-list-authen').addClass('uhide');
			//$('.js-authen').css('background-color','#0a77e0').text('已认证');  
			$('.blueDot').removeClass('uhide');
			$('.js-authen').html('已实名');
		}
		$('.js-lv').text('LV' + localStorage.getItem("level"));
		$('.js-jifen').text(localStorage.getItem("active"));
		$('.js-userRank').text(localStorage.getItem("userRank"));
		var j = {
			'function': 'NF060',
			'lognumber': Decrypt(sessionStorage.getItem("idno")),
			'certificatetype': localStorage.getItem("idtype"),
			'accountId': sessionStorage.getItem("accountId"),
			'sessionkey': getLocVal('sessionkey'),
			'lastSeeMsgDate': getLocVal("lastSeeMsgDate"),
			'custType': localStorage.getItem("custType"),
			'scope': '1',
			'interfaceversion': '3'
		}
		toast();
		nfApp._ajax(j, function(data) {
			closeToast();
			if(data.code == SUCCESS_FLAG) {
				if(data.focus != undefined) {
					$('#focusCount').text(data.focus);
				}
				if(data.plan != undefined) {
					$('#planCount').text(data.plan);
				}
				if(data.bank != undefined) {
					$('#bankCount').text(data.bank);
				}
				if(data.msg != undefined) {
					if(data.msg && (data.msg != 0)) {
						showMesCount(data.msg);
					} else {
						$(".mes-count").addClass('uhide');
					}

					// if(data.msg > 99){
					// $('#msgCount').text("99+");
					// }else{
					// $('#msgCount').text(data.msg);
					// }
				} else {
					$(".mes-count").addClass('uhide');
				}
				if(data.active != undefined) {
					$('.js-jifen').text(data.active);
					$('.js-lv').text('LV' + data.level);
					setLocVal("level", parseInt(data.level));
					setLocVal("active", data.active);
					setLocVal("total", data.total);
				}
				if(data.managerName) {
					setLocVal('managerName', data.managerName);
					setLocVal('managerMobile', data.managerMobile);
					$("#vip").removeClass('uhide');
				}
			} else if(data.code == Time_OUT) {
				handletimeout("login.html?#p_view_more", showUserinfo); //超时重新登录
			}
		});
	}

	// $('.js-list-authen').removeClass('uhide');
	// $('#vip').removeClass('uhide');
});

//对头部进行变化
// $('.virtualTitle').css({display:'none !important'});
// $('.virtualTitle[page="p_view_more"]').css({display:''});

//判断是否显示头部
isHideTitle(browser.versions.mobile);